package org.xg.study.pd.test;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xg.study.pd.group.Employee;
import org.xg.study.pd.group.GroupStructure;
import org.xg.study.pd.group.Link;
import org.xg.study.pd.lang.Iterator;

/**
 * @author CMG
 * @version 1.0
 * @description
 * @cLassName ApiTest15_00
 * @date 2021/9/16 15:56
 **/
public class ApiTest15_00 {
    private Logger logger = LoggerFactory.getLogger(ApiTest15_00.class);

    @Test
    public void test_iterator() {
        GroupStructure groupStructure = new GroupStructure("1", "xg");
        groupStructure.add(new Employee("2", "花花", "二级部门"));
        groupStructure.add(new Employee("3", "豆包", "二级部门"));
        groupStructure.add(new Employee("4", "蹦蹦", "三级部门"));
        groupStructure.add(new Employee("5", "大烧", "三级部门"));
        groupStructure.add(new Employee("6", "虎哥", "四级部门"));
        groupStructure.add(new Employee("7", "玲姐", "四级部门"));
        groupStructure.add(new Employee("8", "秋雅", "四级部门"));

        groupStructure.addLink("1", new Link("1", "2"));
        groupStructure.addLink("1", new Link("1", "3"));

        groupStructure.addLink("2", new Link("2", "4"));
        groupStructure.addLink("2", new Link("2", "5"));

        groupStructure.addLink("5", new Link("5", "6"));
        groupStructure.addLink("5", new Link("5", "7"));
        groupStructure.addLink("5", new Link("5", "8"));

        Iterator<Employee> iterator = groupStructure.iterator();
        while (iterator.hasNext()) {
            Employee employee = iterator.next();
            logger.info("{}, 雇员 Id: {}, Name: {}", employee.getDesc(), employee.getUId(), employee.getName());
        }
    }
}
